package secret.hehe.com.secret.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by DELL on 2018/1/19.
 */

public class DatabaseHelper extends SQLiteOpenHelper {

    public static final String CREATE_USERS = "create table user("
            + "id text,"
            + "pwd text,"
            + "icon text,"
            + "PRIMARY KEY(id) )";

    public static final String CREATE_CONTACT = "create table address("
            + "aid text,"
            + "user1 text,"
            + "user2 text,"
            + "nickname text,"
            + "isscreen text,"
            + "keyhead text,"
            + "PRIMARY KEY(aid)  )";


    public static final String CREATE_MESSAGE = "create table message("
            + "eid text,"
            + "sendid text,"
            + "recvid text,"
            + "sendtime text,"
            + "title text,"
            + "abstract text,"
            + "common_type	text,"
            + "common_content	 text,"
            + "hidden_type	text,"
            + "hidden_content text,"
            + "ishidden text,"
            + "issend text,"
            + "isbin text,"
            + "isdel text,"
            + "PRIMARY KEY(eid)  )";


    public static final String CREATE_COLLECTION = "create table collection("
            + "userid text,"
            + "eid text)";

    private Context mContext;

    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        try{
            db.execSQL(CREATE_USERS);
            db.execSQL(CREATE_CONTACT);
            db.execSQL(CREATE_MESSAGE);
            db.execSQL(CREATE_COLLECTION);
        }catch (Exception e){

        }

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
